RotationComposer
Rotates the camera to keep the target at screenPosition. With a deadZone the target can move freely inside it before the camera turns, and damping makes the turn smooth. With the default settings it behaves like HardLookAt.
The zones react to the target's edge, not just its center, so its size matters. klipp.setSize keeps the screen proportions in sync with your viewport. With an orthographic camera, the screen spans orthographicSize at any distance.
Settings
Combining with PositionComposer
When pairing it with PositionComposer, use the same screenPosition on both, and give both a non-zero deadZone. Without a dead zone on each side they cancel each other out.
Usage
import { RotationComposerAim, targetPose } from '@pmndrs/klipp';
const player = targetPose.create(); // keep player.position up to date
player.extent.radius = 0.5; // so the zones react to its edge
camera.aim = new RotationComposerAim(player, { deadZone: [0.2, 0.2], damping: 0.3 });
The target's size comes from player.extent, and its rotation is only used for targetOffset.
import { RotationComposerAimThree } from '@pmndrs/klipp/three';
camera.aim = new RotationComposerAimThree(player, { deadZone: [0.2, 0.2], damping: 0.3 });
For meshes, the target's size is measured from its geometry. If the shape changes (an animated skinned mesh, for example), call recalculateSize() to measure it again.
<VirtualCamera name="follow" priority={10}>
<Body.Follow target={playerRef} offset={[0, 3, 8]} damping={0.5} />
<Aim.RotationComposer target={playerRef} deadZone={[0.2, 0.2]} damping={0.3} />
</VirtualCamera>
For meshes, the target's size is measured from its geometry. ref gives you the RotationComposerAimThree: if the shape changes (an animated skinned mesh, for example), call recalculateSize() to measure it again.