Skip to content

C API: The frame

sona_view holds doubles, as the JavaScript keeps plain numbers: the camera maths runs in double and stores float matrices only at the end.

Field Meaning
eye[3], target[3] Up is always +Y (look-at, left-handed), as the web camera
fov_deg Vertical field of view in degrees; default 28.65, as the web
near_z Default 0.05
far_z Default 200 (the web SDK's; the editor uses 20)
width, height The target size in pixels, for LOD and culling

sona_frame_stats reports one update: ms (the dt passed in), cpu_ms (time inside sona_update), drawn, culled, draw_calls (main-pass draws of the last sona_draw) and built (build steps run).

sona_scene_stats is the running picture, as the web's stats(): fps, ms_per_frame, p95_ms, cpu_ms_per_frame, avatars, ready, queued, drawn, draw_calls, geometries, textures, gpu_mb, cpu_mb, build_ms_avg, build_ms_max, and long_frames (frames over the 33.4 ms threshold, counted over a window set to 2 s).

sona_view_defaults

void sona_view_defaults(sona_view *v);
Parameter and type Meaning
v
sona_view *
The sona_view to fill with the defaults (required)

Returns Nothing.

Example:

sona_view x_view;
sona_view_defaults(&x_view);
sona_camera_preset(avatar, SONA_PRESET_FULL, &x_view);
sona_view_defaults(&x_view);

The web's full-body framing.

sona_update

sona_result sona_update(sona_ctx *ctx, double dt_seconds,
                        const sona_view *view, sona_frame_stats *out);
Parameter and type Meaning
ctx
sona_ctx *
The context (required)
dt_seconds
double
Seconds since the last update
view
const sona_view *
The camera, a sona_view (NULL allowed (below))
out
sona_frame_stats *
Receives the sona_frame_stats (required)

Returns SONA_OK. Errors SONA_E_ARGUMENT, SONA_E_LIMIT, SONA_E_IO, SONA_E_GATE (what each means).

Example (also in The NPC kit (sona_npc)):

sona_npc_update(npc, dt);
sona_update(ctx, dt, NULL, NULL);

sona_npc_state st;
st.size = sizeof st;
/* SONA_NPC_IDLE, _SPEAKING (st.line), _EMOTING; st.queued */
sona_npc_state_get(npc, &st);

Advances every avatar by dt_seconds (clamped to 0..0.1 s, as the web), runs build steps inside the build budget, culls against the view and poses what is due (the web's LOD rules). It also drains finished reads and jobs. view may be NULL: then nothing is culled and every avatar poses every frame. The view is used only for culling and LOD; palettes are folded with each draw's own view in sona_draw and sona_snapshot.

sona_stats

void sona_stats(const sona_ctx *ctx, sona_scene_stats *out);
Parameter and type Meaning
ctx
const sona_ctx *
The context (required)
out
sona_scene_stats *
Receives the sona_scene_stats (required)

Returns Nothing.

Example:

sona_scene_stats x_scene_stats;
memset(&x_scene_stats, 0, sizeof x_scene_stats);
sona_stats(ctx, &x_scene_stats);

Fills *out with the scene statistics.

This page as Markdown · All the docs as one file (llms-full.txt)