Reference slerp()

slerp()

Sets the camera’s position and orientation to values that are in-between those of two other cameras.

myCamera.slerp() uses spherical linear interpolation to calculate a position and orientation that’s in-between two other cameras. Doing so is helpful for transitioning smoothly between two perspectives.

The first two parameters, cam0 and cam1, are the p5.Camera objects that should be used to set the current camera.

The third parameter, amt, is the amount to interpolate between cam0 and cam1. 0.0 keeps the camera’s position and orientation equal to cam0’s, 0.5 sets them halfway between cam0’s and cam1’s , and 1.0 sets the position and orientation equal to cam1’s.

For example, calling myCamera.slerp(cam0, cam1, 0.1) sets cam’s position and orientation very close to cam0’s. Calling myCamera.slerp(cam0, cam1, 0.9) sets cam’s position and orientation very close to cam1’s.

Note: All of the cameras must use the same projection.

Examples

Syntax

slerp(cam0, cam1, amt)

Parameters

cam0
p5.Camera:

first camera.

cam1
p5.Camera:

second camera.

amt
Number:

amount of interpolation between 0.0 (cam0) and 1.0 (cam1).

Notice any errors or typos? Please let us know. Please feel free to edit src/webgl/p5.Camera.js and open a pull request!

Related References