Framing and starting options
Put these in theconfig of the session token request on your server, next to faceId:
This route starts a 16:9 session with the camera zoomed in a little:
app/api/simli-token/route.ts
422. See Framing the video for how the canvas is filled.
Changing the camera, background and foreground during a session
Oncestart() has resolved, three methods change the avatar live:
setCamera
setCamera(camera, { lerpSeconds }) moves the camera. Each call replaces the whole camera, the session’s starting one included. Its values are offsets from the avatar’s own framing, not from the previous call, so fields you leave out are neutral, and null goes back to the avatar’s own framing. It cuts to the new camera, unless lerpSeconds is above 0: then it glides there over that many seconds, from wherever the camera is now.
It throws on a value that isn’t a finite number, and if the connection isn’t open. The fields and their ranges are in CameraSetting.
setBackground and setForeground
Upload the image first, then pass the id the upload returned. setBackground(id) shows it behind the avatar, and setForeground(id) lays it over the avatar through its transparency. null goes back to the avatar’s own background, or takes the foreground away.
The new image shows a moment later, once it has loaded, and if you send several, the last one wins. Both throw if the id isn’t the 36-character one the upload returned.
Notices
Simli answers some of these calls with a notice, which arrives as thewarning event. None of them end the session: