Follow
Keeps the camera at a fixed offset from a target.
Keeps the camera at offset from the target. By default the offset turns with the target, so a chase camera stays behind a character as it turns.
Settings
bindingMode
A target without rotation, like a fixed point, always uses world space.
The binding mode also tells Aims like HardLookAt which way is up, so with lockToTarget the camera rolls along with the target, and with lockToTargetWithWorldUp it never does.
Usage
import { FollowBody, HardLookAtAim, targetPose } from '@pmndrs/klipp';
const player = targetPose.create(); // keep player.position and player.rotation up to date
camera.body = new FollowBody(player, { offset: [0, 3, 8], damping: 0.5 });
camera.aim = new HardLookAtAim(player);
Every binding mode but worldSpace turns the offset with the target, so fill in player.rotation and set player.hasRotation.
bindingMode
import { FollowBody, targetPose } from '@pmndrs/klipp';
const plane = targetPose.create(); // keep plane.position and plane.rotation up to date
camera.body = new FollowBody(plane, { offset: [0, 2, 10], bindingMode: 'lockToTargetWithWorldUp' });
import { Vector3 } from 'three';
import { FollowBodyThree, HardLookAtAimThree } from '@pmndrs/klipp/three';
camera.body = new FollowBodyThree(player, { offset: new Vector3(0, 3, 8), damping: 0.5 });
camera.aim = new HardLookAtAimThree(player);
bindingMode
import { Vector3 } from 'three';
camera.body = new FollowBodyThree(plane, { offset: new Vector3(0, 2, 10), bindingMode: 'lockToTargetWithWorldUp' });
<VirtualCamera name="chase" priority={10}>
<Body.Follow target={playerRef} offset={[0, 3, 8]} damping={0.5} />
<Aim.HardLookAt target={playerRef} />
</VirtualCamera>
ref gives you the FollowBodyThree.
bindingMode
<Body.Follow target={planeRef} offset={[0, 2, 10]} bindingMode="lockToTargetWithWorldUp" />