Rotate the object towards the direction of the camera

Hello dear community!
I have been studying the docs and practicing for a week now and have a lot of fun with it!
I have an object in the scene that is specified as a target for the camera

const controls = new OrbitControls(camera, renderer.domElement);

By pressing the keys, I move the object and the camera follows it perfectly
I would like the object to be turned towards the direction of the camera.
i tried to do so
modelMesh.rotation.y = camera.rotation.y;
but in this case the object does not always turn in the right direction

help plz
photo_2020-10-17_13-12-08

Please try it with the approach from this example:

The idea is to specify a target orientation and then use Quaternion.rotateTowards() to gradually rotate the object to its new focus point.

1 Like

Thanks for the answer, thanks to you I figured out the rotation to the point

The object turns smoothly and nicely towards the camera thanks to this code,

targetQuaternion = camera.quaternion;
  if (!modelMesh.quaternion.equals(targetQuaternion)) {
    var step = rotationSpeed * delta;
    modelMesh.quaternion.rotateTowards(targetQuaternion, step);
  }

but I need, in the opposite direction, is there a way to invert?

rotateTowards() always uses the shortest path to transform from a given orientation to a target one. It’s not possible to influence this process. TBH, I’m not sure how to implement what you are looking for.