How to get the Distance in OrbitControls and PerspectiveCamera

I’m using OrbitControls and PerspectiveCamera now.

And I can control the focal length of the camera by setting maxDistance and minDistance in OrbitControls.

But how to get the current real-time focal length.

OrbitControls has a target property which represents the focus point of the controls. Have you tried to compute the distance between the camera’s position and OrbitControls.target like so?

const distance = camera.position.distanceTo( controls.target );
1 Like

I’ve solved it in this way.
Thank you very much.