Skip to content

Playground

Pick a costume, a clip, a prop, the camera, the shadow and the background. The avatar changes as you pick, drawn by the web SDK, and the code under it changes to match: C for the native SDK and JavaScript for the web SDK, the same settings in each. The copy button in the corner of the code copies it as it stands.

The avatar the code below draws.
The avatar the code below draws.

The code

The code holds the picked costume's manifest (its 1,000 bytes as base64) as manifestBase64 (manifest_b64 in C), so it runs as copied; for your player's own, take theirs from 360sona.com's share box or GET /sona/v1/avatar/random. In C the lines go where getting started puts them, with its names (ctx, avatar, renderer, view, target): the avatar after the context is open, the framing once it is ready, the draw in the frame loop.

/* The "Harry Potter's Robe and Scarf" costume's manifest, as base64 */
static const char manifest_b64[] =
  "AAAAAL8o9cM9TMzNABAAAAMgAAPByPEJoZyy4AAIAAADMwADwcjxCaGcsuAAIAAA"
  "AzoAA8HI8QmhnLLgAACAAALwAAPByPEJoZyy4D+AAAAAAAAAAAAAAAAAAAAAACAA"
  "AroAA8HI8QmhnLLgP4AAAAAAAAAAAAAAAAAAAAAAQAACdwADwcjxCaGcsuA/gAAA"
  "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
  "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
  "AAAAAAAAAAAAAAAA///gvf+nhWr/sFdP/2uOm/+nhWr/i2tc/6eFav/JoKD/yaCg"
  "AAAAAgABAALByPEJoZyy4AACAAAAAAAAAAAAAAAAAAAAAAABAAIAA8HI8QmhnLLg"
  "AAEAAAAAAAAAAAAAAAAAAAAAAAQB+AADwcjxCaGcsuAABAAAAAAAAAAAAAAAAAAA"
  "AAACOEF50rLPEJpLV0IH5wI4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
  "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
  "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
  "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
  "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
  "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
  "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
  "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
  "AAAAIB5DUoLNF8eRRE0H7AAgAAAAAAAAAAAAAAAAAAAAAAAQFV2yUsLLkZBNMQfR"
  "ABAAAAAAAAAAAAAAAAAAAAAAAAhOd4IywK89nTc5B9EACAAAAAAAAAAAAAAAAAAA"
  "AAAABAH4AAPByPEJoZyy4AAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
  "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
  "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==";

sona_add_options add;
sona_add_defaults(&add);
add.clip = "GenericWave";
sona_avatar_add_base64(ctx, manifest_b64, &add, &avatar);

/* once it is READY */
sona_camera_preset(avatar, SONA_PRESET_FULL, &view);

sona_draw_options draw = { { 0, 0, 0, 0 }, 0, SONA_CORNER_BOTTOM_RIGHT };
/* each frame, after sona_update */
sona_draw(renderer, &view, &target, &draw);
import { SonaRenderer } from './sona-renderer.js';

// The "Harry Potter's Robe and Scarf" costume's manifest, as base64
const manifestBase64 =
  'AAAAAL8o9cM9TMzNABAAAAMgAAPByPEJoZyy4AAIAAADMwADwcjxCaGcsuAAIAAA'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IB5DUoLNF8eRRE0H7AAgAAAAAAAAAAAAAAAAAAAAAAAQFV2yUsLLkZBNMQfR' +
  'ABAAAAAAAAAAAAAAAAAAAAAAAAhOd4IywK89nTc5B9EACAAAAAAAAAAAAAAAAAAA' +
  'AAAABAH4AAPByPEJoZyy4AAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' +
  'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' +
  'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==';

const canvas = document.querySelector('canvas');
const sona = await SonaRenderer.create({ canvas });
const avatar = sona.add(manifestBase64, { clip: 'GenericWave' });
await avatar.ready;
sona.camera.preset('full', avatar);

What each picker sets

In C:

Picker What it sets
Costume The manifest given to sona_avatar_add_base64()
Clip add.clip, or sona_avatar_play() later
Prop sona_prop_mesh_stock(), then sona_avatar_prop_attach() with SONA_PROP_PERFORM
Camera sona_camera_preset() into your sona_view; with a prop, sona_camera_orbit()
Shadow SONA_DRAW_SHADOW in sona_draw_options.flags
Background sona_draw_options.clear, premultiplied RGBA

In JavaScript:

Picker What it sets
Costume The manifest given to sona.add()
Clip clip of add(), or avatar.play() later
Prop avatar.wear(id), then avatar.play('prop')
Camera sona.camera.preset(); with a prop, sona.camera.orbit()
Shadow shadow: true when made, or sona.shadow
Background background, premultiplied RGBA

The clips are keys of sona.clips() (sona_stock_clip_count and the clip table in C), the props are stock items, and the framings are the console's own. Every call is in the web SDK reference and the C API reference.

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