cameraLookAtfunctionnacatamalon
cameraLookAt(camera: TCamera3d, target: { x, y, z }) => TCamera3dTurns a camera to look at a point, from wherever it is standing.
It writes the camera's rotationY (left and right) and rotationX (up and down), and leaves its
roll alone. Call it in useUpdate to keep a moving thing in the middle of the view. A camera
turned by a quaternion is switched back to angles, since a quaternion would be read instead of
them and the camera would not move.
Straight up or straight down has no left or right to speak of, so there the camera keeps the
rotationY it had.
Parámetros
cameraTCamera3dThe camera to turn.
target{ x, y, z }Where to look: anything with
x,yandz, such as another object's placement.
Ejemplo
declare const player: TTransform3d;
const camera = useCamera3d({ projection: 'perspective', fov: 60, y: 3, z: 6 });
useUpdate(() => cameraLookAt(camera, player));