How to calculate the direction of the two coordinates

I want to click on the floor, and let the model move towards the point of click. At present, the model can move over, but how to make the model face the point

Using Mesh.lookAt() might be helpful here.


This will rotate your model on 3 axis so that it faces the clicked point. This assumes your model was designed with the positive Z axis representing “forward”.

If your model rotates on more axes than you want it to you may need to manually replace some of the axis values. For example…

// Rotate the model only around the world Y axis.
const facePoint = clickPoint.clone();
facePoint.y = myModel.position.y;

If the above doesn’t meet your objective, I suggest creating a Playground to share with us so we can understand your goals and current code better.


Thanks! :grin: