简体   繁体   中英

How to rotate camera towards point in 3d?

I've got a camera somewhere in a 3d space. I need to calculate angle between camera and a given point .

I can't use lookAt() method (nor any built-in Controller ), because I'm also rotating camera on mousemove and want to animate the rotation.

In a word: how to change camera.rotation to make it look at specified point?

The typical approach for rotating a 3D object towards a target is the usage of Quaternion.rotateTowards() . It's usage is demonstrated in the official example webgl_math_orientation_transform .

The important bit of this approach is:

camera.quaternion.rotateTowards( targetQuaternion, step );

targetQuaternion represents the target orientation whereas step represents the angular step in radians. This value should honor the time delta for a correct animation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM