Lens
Changes fov, orthographic size, near and far, with damping.
Sets the camera's fov, orthographicSize, near and far. Leave one out to keep the current value. Each one can be damped separately, for effects like a speed zoom.
Set lens values through Lens, not on the real camera directly. Klipp writes the lens every time the shot changes, so direct changes get overwritten, for example by the next blend.
Settings
Usage
import { LensExtension } from '@pmndrs/klipp';
const lens = new LensExtension({ fov: 50, fovDamping: 0.4 });
camera.addExtension(lens);
// any time later
lens.fov = boosting ? 75 : 50;
import { LensExtension } from '@pmndrs/klipp';
const lens = new LensExtension({ fov: 50, fovDamping: 0.4 });
camera.addExtension(lens);
// any time later
lens.fov = boosting ? 75 : 50;
<VirtualCamera name="chase" priority={10}>
<Body.Follow target={carRef} offset={[0, 2, 6]} />
<Aim.HardLookAt target={carRef} />
<Extension.Lens fov={boosting ? 75 : 50} fovDamping={0.4} />
</VirtualCamera>
ref gives you the LensExtension. To change the lens every frame without re-rendering, set its fields directly:
const lens = useRef<LensExtension>(null);
useFrame(() => {
lens.current.fov = 50 + speed * 0.5;
});