Skip to main content
Trinity-2 faces take a video size and an avatar position, a camera you can move during the session, and your own backgrounds and foregrounds. Other faces ignore these options, but the session token request still checks the framing fields.

Framing and starting options

Put these in the config 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
A size that isn’t 1:1, 16:9 or 9:16, a side under 512 or a position outside 0 to 1 makes the request fail with a 422. See Framing the video for how the canvas is filled.

Changing the camera, background and foreground during a session

Once start() 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 the warning event. None of them end the session: