Make mesh look at clicked point, with transition

Hello Everyone,

I am trying to make a mesh face a clicked position similar to what is achieved with mesh.lookat() here:

But I want a gradual rotation with a transition, instead of an instant change. Is there a way to do this?

If you look at the code which is commented out, you’ll see my attempt to use trigonometry to calculate the amount of rotation needed, but my powers are weak…

If I can figure out the correction rotation needed to rotate to the destination, I think I can animate it with a scene.onBeforeRenderObservable

Am I going about this the right way? Is there any chance one of you smart folks could give me a hint?

My attempt at trig:

There were two excellent replies here before but they seem to be gone now. Here’s the playgrounds in case anyone else may find the solution useful:

Also there’s some more info here may be useful to others, but I couldn’t understand it too well myself. I’m still looking it over.

2 Likes