dollyZoomTo

fun dollyZoomTo(distance: Double, instant: Boolean = false)(source)

Dollies to distance the way DemoGeneralizedPerspective01 establishes a dolly zoom -- compensating fov as the eye moves so whatever sits at lookAt keeps the same apparent size, leaving only the depth-dependent stretch/compression (the Vertigo effect) visible elsewhere in the scene. The demo derives its viewport size from subjectDistance / distance; since fov plays the same role here that viewport size did there (both feed the same 2 * distance * tan(fov / 2) viewport-height formula beforeDraw uses -- see the class doc), the equivalent invariant to hold is distance * tan(fov / 2) = constant. That constant is taken from the current target (sphericalEnd's radius and fovEnd) at the moment this is called, not spherical/fov directly, so chained or repeated calls compose the way dolly/zoom do instead of resetting to whatever framing happened to be on screen.

distance and the compensated fov are both damped like any other orbit property -- during the transition the invariant is only approximate (each eases independently, at the same rate), settling to exact once both reach distance and the new fovEnd.