FollowZoom

Keeps a target the same size on screen by changing the field of view.

Changes the field of view so the shot stays width wide at the target's distance. As the target moves closer or farther, it keeps its size on screen. Move the camera toward the target at the same time for a dolly zoom: the target stays put while the background stretches.

It runs right after the Body, before the Aim, so the Aim, like RotationComposer, frames with its field of view. Its target is usually the one the Aim looks at.

With an orthographic camera, distance doesn't change how big the target looks, so it sets orthographicSize to show width across instead, and fovRange doesn't apply.

Settings

SettingDescriptionDefault
targetWhat to keep the same size. See Targets.
widthHow wide the shot is at the target's distance, in world units.2
dampingSeconds to settle on a new field of view or orthographic size. See Damping.1
fovRangeLowest and highest field of view it sets, [min, max] in degrees, within [1, 179].[3, 60]

Usage

import { FollowZoomExtension, HardLookAtAim } from '@pmndrs/klipp';

camera.aim = new HardLookAtAim(player);
camera.addExtension(new FollowZoomExtension(player, { width: 3, damping: 0.5 }));