What is the best practice for zooming when picking area?

I have an glb file composed from different parts, i’m using raycast for selecting each part - i wonder how can i zoom in the part (and out) when picking, i’m relaying on This Example so if any suggestions with references or related to this example will be much appreciated ! :slight_smile:

You can use a technique called dollying which is also used by OrbitControls to implement zooming with perspective cameras. Since you know the current position of your camera, you only have to figure out the center point of your picking area. If the area is a triangle, you can simply use the mid point. The actual intersection point of the raycast is also a good candidate.

If you subtract the intersection point from the camera position (both defined in world space) and normalize the resulting vector, you have the look direction from the camera to the intersection point. If you multiply this direction vector with a scalar value (which represents the zoom value), you can actually animate the camera along this vector until you reach a proper position in front of the destination point.

3 Likes

Thanks - can you add any example? i can’t find a clear reference to dollying a camera in this way…