Props: held and worn objects¶
A prop is any mesh on any joint of an avatar: a guitar, a sword, a balloon, a phone, a hat, a pet at its feet. The
mesh is the host's own (triangles, or a glTF 2.0 file) or a stock prop item of the catalogue, read through the ctx's
sources like a worn item. One mesh can be on any number of avatars, up to SONA_PROP_MAX (8) on each, every one
with its own joint and offset. Props are posed from the solved joints, after the clip, the crossfades, the
overrides, the layers and IK, so a prop moves exactly as the hand that holds it. Our backends draw props with their
avatar in sona_draw and sona_snapshot, and so in every output built on them (headless renders, batches,
sequences and videos, stickers, pixel art and sprite sheets). sona_export_avatar writes them into glTF and VRM
files, each a node under its bone. A host that draws its own reads each prop's frame every pose and its meshes once.
The public API (C reference: props) is 23 functions and six sized structs (size = sizeof(struct); the
_defaults functions set it and every other field). Code:
Quick start¶
/* a host glTF file, on the right hand */
sona_prop_mesh *sword = NULL;
char why[160];
if (sona_prop_mesh_open(ctx, "sword.glb", NULL, &sword, why,
sizeof why) != SONA_OK) puts(why);
sona_prop_attach at;
/* joint SONA_PROP_JOINT_AUTO: PropRight for a host mesh */
sona_prop_attach_defaults(&at);
uint32_t id;
sona_avatar_prop_attach(avatar, sword, &at, &id);
/* the avatar keeps its own reference */
sona_prop_mesh_release(sword);
/* a stock pet from the catalogue, performing with its avatar as the
site's pet mode does */
sona_prop_mesh *pet = NULL;
sona_guid g;
char item[SONA_ID_CHARS];
sona_prop_pet(0, &g);
sona_guid_format(&g, item);
/* SONA_PENDING until loaded; attach it already */
sona_prop_mesh_stock(ctx, item, &pet);
sona_prop_attach_defaults(&at);
at.flags = SONA_PROP_PERFORM;
sona_avatar_prop_attach(other, pet, &at, NULL);
/* swap, move, take off */
sona_avatar_prop_swap(avatar, id, stick);
at.position[1] = 0.05f;
/* call each frame for a prop that slides along the joint */
sona_avatar_prop_set(avatar, id, &at);
sona_avatar_prop_detach(avatar, id);
// a host glTF file, on the right hand
sona_prop_mesh *sword = nullptr;
char why[160];
if (sona_prop_mesh_open(ctx.raw(), "sword.glb", nullptr, &sword, why,
sizeof why) != SONA_OK) std::puts(why);
sona_prop_attach at;
// joint SONA_PROP_JOINT_AUTO: PropRight for a host mesh
sona_prop_attach_defaults(&at);
uint32_t id;
sona_avatar_prop_attach(avatar.raw(), sword, &at, &id);
// the avatar keeps its own reference
sona_prop_mesh_release(sword);
// a stock pet from the catalogue, performing with its avatar as the site's
// pet mode does
sona_prop_mesh *pet = nullptr;
sona_guid g;
sona_prop_pet(0, &g);
// SONA_PENDING until loaded; attach it already
sona_prop_mesh_stock(ctx.raw(), sona::format_guid(g).c_str(), &pet);
sona_prop_attach_defaults(&at);
at.flags = SONA_PROP_PERFORM;
sona_avatar_prop_attach(other.raw(), pet, &at, nullptr);
// swap, move, take off
sona_avatar_prop_swap(avatar.raw(), id, stick);
at.position[1] = 0.05f;
// call each frame for a prop that slides along the joint
sona_avatar_prop_set(avatar.raw(), id, &at);
sona_avatar_prop_detach(avatar.raw(), id);
// a host glTF file, on the right hand
var sword = ctx.OpenPropMesh("sword.glb");
// joint auto: PropRight for a host mesh
uint id = avatar.AttachProp(sword);
// the avatar keeps its own reference
sword.Dispose();
// a stock pet from the catalogue, performing with its avatar as the site's
// pet mode does
// still loading; attach it already
var pet = ctx.StockPropMesh(SonaContext.PropPets()[0]);
var at = SonaAvatar.PropAttachDefaults();
at.flags = Native.SONA_PROP_PERFORM;
other.AttachProp(pet, at);
// swap, move, take off
avatar.SwapProp(id, stick);
at = SonaAvatar.PropAttachDefaults();
at.position[1] = 0.05f;
// call each frame for a prop that slides along the joint
avatar.SetProp(id, at);
avatar.DetachProp(id);
// a host glTF file, on the right hand
let sword = ctx.prop_mesh_load(&std::fs::read("sword.glb").unwrap_or_default(), None)?;
// joint auto: PropRight for a host mesh
let id = avatar.attach_prop(&sword, None)?;
// the avatar keeps its own reference
drop(sword);
// a stock pet from the catalogue, performing with its avatar as the site's
// pet mode does
// still loading; attach it already
let pet = ctx.prop_mesh_stock(&prop_pets()[0])?;
let mut at = prop_attach_defaults();
at.flags = sona_sys::SONA_PROP_PERFORM;
other.attach_prop(&pet, Some(&at))?;
// swap, move, take off
avatar.swap_prop(id, stick)?;
let mut at = prop_attach_defaults();
at.position[1] = 0.05;
// call each frame for a prop that slides along the joint
avatar.set_prop(id, &at)?;
avatar.detach_prop(id)?;
# a host glTF file, on the right hand
sword = ctx.prop_mesh_load(path="sword.glb")
# joint "auto": PropRight for a host mesh
pid = avatar.prop_attach(sword)
# the avatar keeps its own reference
sword.release()
# a stock pet from the catalogue, performing with its avatar as the site's
# pet mode does
# still loading; attach it already
pet = ctx.prop_mesh_stock(sona.prop_pets()[0])
other.prop_attach(pet, perform=True)
# swap, move, take off
avatar.prop_swap(pid, stick)
# call each frame for a prop that slides along the joint
avatar.prop_set(pid, position=(0, 0.05, 0))
avatar.prop_detach(pid)
On the web¶
A stock prop is an item: the web SDK's wear() puts it in the avatar's hand, and the clip 'prop' is the prop's
own animation. An avatar carries one at a time; wearing another swaps it:
import { SonaRenderer } from './sona-renderer.js';
const PROPS = {
'Gravity Hammer': '00001000-93a6-02f3-ce94-67884d5309cf',
'Needler Toy Prop': '00001000-c6f4-2253-caa5-9f694d5309cf',
'Luke Skywalker Blue Lightsaber': '00001000-f5bb-f2b3-c3ee-4e434c4107f4',
};
const canvas = document.querySelector('canvas');
const sona = await SonaRenderer.create({ canvas });
const avatar = sona.add(manifestBase64);
await avatar.ready;
await avatar.wear(PROPS['Gravity Hammer']);
avatar.play('prop');
// further out than the full framing: a prop's clip swings it above the head
sona.camera.orbit({
yaw: 0, pitch: 5, distance: 4.5, target: [0, 0.95, 0],
});

The prop frame¶
Each prop has one frame: the joint's frame with its scale removed (its rotation and position, in avatar space), moved by the offset, and grown with the avatar's height as the site's held props are:
v_avatar = ((v * scale) * rotation + position) * body * joint
rotation is a unit quaternion (x, y, z, w) as everywhere in the SDK; position is metres in the joint's frame;
body is the avatar's root height scale (SONA_PROP_NO_BODY_SCALE leaves it out). joint is any sona_joint_find
joint, SONA_PROP_ROOT (the avatar's own space: its feet, facing -Z, the placement applied), or
SONA_PROP_JOINT_AUTO: PropRight for a host mesh; for a stock prop the hand its own clip grips it in, at its grip
frame, or the root for a prop no hand holds (most pets), as on the site.
The joint frames of the rig at a still stance:
| Joint | +X | +Y | +Z |
|---|---|---|---|
PropRight |
up, towards the elbow | to the avatar's right | backwards (the fist's axis) |
PropLeft |
down, towards the fingers | to the avatar's left | backwards |
Head, Chest |
the avatar's left | up | backwards |
So a sword whose blade runs along +Z of a right-handed modelling tool (glTF's forward) hangs point forward from a
loose fist, and a hat on Head with position[1] = 0.15 sits on top.
Meshes¶
- Host triangles:
sona_prop_mesh_createtakes up to 64sona_prop_parts, each one material: positions, optional normals (made from the triangles when NULL), uvs, RGBA8 vertex colours, a triangle list of up to 65,536 vertices, an ARGB colour, an optional straight RGBA8 sRGB picture (copied) and a transparency for the transparent pass. Positions are the avatar's own left-handed space; setSONA_PROP_PART_RIGHT_HANDEDfor data from a right-handed tool: z is negated and the triangles wound back, the same mirror as the glTF export and the clip importer. - glTF 2.0:
sona_prop_mesh_load(bytes:.glbor a.gltfwith embedded buffers) andsona_prop_mesh_open(a UTF-8 path, opened wide on Windows; buffers and pictures next to a.gltfare read too). Every triangle primitive under the scene's nodes, each node's world transform applied, one part per primitive: base colour factor, base colour texture (PNG or JPEG through stb_image), vertex colours, alpha modeBLENDas transparent andMASKas a cut-out at alpha 0.5 (the avatars' own cut-off; the file'salphaCutoffis not read). Skins and morph targets are ignored: the bind pose is drawn.sona_prop_load_optionsscales (metres per file unit), centres the box on the origin, picks a scene, or skips pictures. A refusal says why inwhy. - Stock props:
sona_prop_mesh_stocktakes any carryable item id (mask 0x1000). It loads through a hidden item preview of the ctx (it counts towardmax_avatars; its events never reach the host), keeps the prop's own skeleton and clip, and reportsSONA_OK,SONA_PENDINGor why it failed throughsona_prop_mesh_state.sona_prop_mesh_info_getgives its joints, the hand it is gripped in, its clip length and its box. - Pets:
sona_prop_pet_countandsona_prop_petlist the catalogue's pets, the same list as the site's pet mode;sona_prop_is_petanswers for one id. Names come from the catalogue (sona_catalogue_find).
Props draw with the avatars' cloth program (the irradiance light, the rim, the key light's shadow): colour is texture times part colour times vertex colour. The mesh is shared: each renderer uploads it once, as it does an item many avatars wear.
Stock props and their clips¶
| Flags | What the prop does |
|---|---|
| none | holds its grip (or fullest) frame, rigid on its joint, exactly as the site holds an extra prop |
SONA_PROP_PLAY |
its own clip runs on its own clock (speed, start_at; loops unless SONA_PROP_ONCE), relative to the hand at the grip frame |
SONA_PROP_PERFORM |
the avatar plays the prop's own avatar clip (sona_avatar_play with the item id) and the prop runs on that clip's clock in the avatar's own space: the site's pet mode performance. The anchor is the root whatever joint says |
A performance prop authored with a stage (some carryables bring a whole scene with their clip) shows that stage in
the grip frame too, as on the site; to hold one still in a hand, pick a prop made to be held (its
sona_prop_mesh_info.hand is not -1). When a stock prop's item preview rebuilds, every prop on it takes its joint
and grip again.
Two hands¶
hand puts a second hand on the prop through IK: SONA_IK_LEFT_HAND or SONA_IK_RIGHT_HAND, with
hand_position (the palm, or the wrist with SONA_IK_WRIST), optional hand_rotation (SONA_IK_ROTATION) and
hand_pole (SONA_IK_POLE), all in the prop frame. The prop sets that hand's sona_ik_target, relative to the
prop's joint, so the solve sees the joint where the clip and the earlier limbs left it; the hand eases on and off
over fade_seconds, and sona_avatar_prop_frame reports how far the palm is from its point (hand_error). The
second hand must not be on the arm the prop hangs from (SONA_E_ARGUMENT at attach for the obvious cases; the rig
check in the update leaves the hand free and logs for the rest).
A guitar (samples/c/props_scene.c): the guitar hangs from Chest on its strap, the left hand holds the neck through
hand, and the right hand strums through a target of the host's own relative to the chest. Gripped in the right hand
instead, the left hand reaches the neck the same way. hand_error is the IK's own distance from the palm to its
point on the prop; the sample's --check fails when either hand of the guitarist is over a limit of 2 cm off.
Hosts that draw props themselves¶
sona_prop_mesh_data: the meshes in the data API's own form: 76-byte vertices whose joint bytes index the prop's palette (a host mesh uses joint 0 only), materials, textures. Upload once per mesh.sona_avatar_prop_frameafter eachsona_update:world(row-vector, metres, placement applied),avatar(before the placement),palette(864 floats laid out assona_pose_data.palette, avatar space, valid until the next update) and flags:POSED,READY,DRAWN. A rigid host mesh needs onlyworld.sona_avatar_prop_vertices: CPU skinning of one prop mesh, avatar or world space, likesona_pose_vertices.
Outputs¶
| Output | Props |
|---|---|
sona_draw, sona_snapshot on every backend |
drawn: opaque parts after the avatars' opaque draws, transparent parts last |
headless renders, batches, sequences, sona_headless_record videos |
drawn (they render through sona_snapshot) |
| stickers, sprite sheets, pixel art | drawn; the cut-out is framed by the avatar's own box, so a long prop may be cut at the edge |
crowd sprites (SONA_LOD_SPRITE) |
not drawn: a baked sprite has no props, so keep sprite_px below the size props matter at |
glTF and VRM export (sona_export_avatar) |
written: a node under its bone (below) |
3D print (sona_print_avatars) |
not printed (it prints a clip's own held prop, not attached ones) |
sona_pose |
the avatar's own data only; props come from the calls above |
In glTF and VRM files¶
sona_export_avatar (GLB, VRM 1.0 and VRM 0.x, VRM and glTF export) writes every prop whose mesh is ready and that is
not SONA_PROP_HIDDEN. SONA_EXPORT_NO_PROPS leaves them out; an avatar without props gives the same bytes as
before.
- A node per prop, under its bone:
prop_<id>, a child of its joint's bone node (a root prop sits at the scene's top, or under UE'sroot), whosetranslation,rotationandscaleput it at the prop frame of the file's rest pose: the offset it was attached with, on the joint as the T-pose has it. It is rigid and not skinned, so whatever moves the bone moves the prop, and a host can unparent or swap it. Itsextrasname the prop id, the joint and, for a stock prop, the item. - Its mesh in the prop frame, mirrored as the avatar is (z, or x for VRM 0.x), a primitive per part. Props on one
mesh share it in the file. A part of one colour gets it as the material's base colour (linear, as glTF wants;
MToon's shade follows it), a part of several as linear vertex colours. Pictures go through the same flattening as
the avatar's (a host texture goes in as is); opaque,
MASKat 0.5 orBLEND, as drawn. - Stock props are written as they stand: a still one at its grip (or fullest) frame, one whose clip runs (
PLAY,PERFORM) as the last update posed it, with a mesh of its own. Its skeleton and clip are not in the file. - Not in the file: the second hand (an IK target; the file has no clips, so the host's own IK puts that hand on the prop), and offsets a host changes each frame (the one at the time of the export is written: the sample's balloon, turned to stay upright while its hand waves, points sideways in the T-pose).
In GLB, VRM 0.x and VRM 1.0 every prop is a node under its bone, skinned by that bone, where the native pose has it to float precision; textured, transparent and hidden props and a prop's own clip included. The files pass the Khronos glTF validator and load in three-vrm with their props.
Culling¶
The culling sphere is the avatar's: a prop far outside its body (a long flag pole) can vanish at the frame's edge a little before the avatar does.
Cost¶
Nothing when no prop is attached: the pose, the update and the frame each read one pointer. With props, each prop's frame is one matrix product per pose (a stock prop with its clip samples it once), and each drawn prop adds one constant block and a draw per part. Stock prop meshes and pictures are shared with avatars wearing the item.
Threads and determinism¶
Props pose on the posing threads with their avatar and give the same bits on any thread count. Every call is made on the owner thread, as every avatar call.
Third-party code¶
glTF is read through cgltf (MIT, already fetched for imported clips); PNG and JPEG pictures through stb_image 2.30
(MIT or public domain), pinned by SHA-256 in cmake/props.cmake and recorded in native/THIRD-PARTY.txt.
-DSONA_WITH_PROP_IMAGES=OFF leaves the pictures out (props keep their base colours and say
SONA_PROP_INFO_UNTEXTURED).
Big-endian hosts. glTF props load on big-endian hosts too (the Xbox 360, PowerPC). cgltf reads the GLB header and accessor data in host order, so there the header is swapped first and each accessor, and a sparse accessor's indices and values, reads a host-order copy of its own bytes; the file's buffers and pictures are left as they are. A file loads, or is refused, the same on either byte order. A sparse accessor's values are read packed, as glTF lays them out, on every host.
This page as Markdown · All the docs as one file (llms-full.txt)